package fr.umlv.galcon.ship;

import java.awt.Color;
import java.awt.Graphics2D;

import fr.umlv.galcon.utils.Utils;

/**
 * This class manages the selection of a Ship.
 * 
 */
public class ShipSelectorManager {
    private final Squadron squadron;

    private int blink;
    private boolean circleSelected;

    /**
     * Constructor
     * 
     * @param squadron
     *            The squadron which owns the ship.
     */
    public ShipSelectorManager(Squadron squadron) {
	this.squadron = squadron;
    }

    /**
     * Set the blink of the Ship.
     * 
     * @param g
     *            Graphics2D object where the Item is drawn.
     */
    public void blinkSelection(Graphics2D g) {
	this.blink++;
	if (this.blink % 2 == 0 && this.squadron.isSelected()) {
	    g.setColor(Color.CYAN);
	    this.blink = 0;
	} else {
	    g.setColor(Utils.getPlayerColor(this.squadron.getOwner().getId()));
	}
    }

    /**
     * Get if the Ship has been selected with a CTRL + mouse wheel selection.
     * 
     * @return A boolean which informs if it has been selected with a CTRL +
     *         mouse wheel selection or not.
     */
    public boolean isWheelSelected() {
	return this.circleSelected;
    }

    /**
     * Set if the Ship has been selected with a CTRL + mouse wheel selection.
     * 
     * @param circleSelected
     *            The new value.
     */
    public void setWheelSelected(boolean circleSelected) {
	this.circleSelected = circleSelected;
    }
}
